package se.nikmel.AnDisper.DisperServer;

import java.io.Serializable;
import java.util.Date;

/**
 * Stores info about a remote server. Instances are stored in the map of servers
 * seen, and saved as a preference
 * 
 * @author niklas
 * 
 */
public class ServerInfo implements Comparable<ServerInfo> , Serializable {
	private static final long serialVersionUID = -5273064353425542058L;
	private String m_sIP;
	private String m_sName;
	private Date m_dteLastSeen;

	public ServerInfo(String p_sIP, String p_sName, Date p_dteSeen) {
		m_sIP = p_sIP;
		m_sName = p_sName;
		m_dteLastSeen = p_dteSeen;
	}

	public String getIP() {
		return m_sIP;
	}

	public void setIP(String p_sIP) {
		this.m_sIP = p_sIP;
	}

	public String getName() {
		return m_sName;
	}

	public void setName(String p_sName) {
		this.m_sName = p_sName;
	}

	public Date getLastSeen() {
		return m_dteLastSeen;
	}

	public void setLastSeen(Date p_dteLastSeen) {
		this.m_dteLastSeen = p_dteLastSeen;
	}

	@Override
	public String toString() {		
		return getName() + " " + getIP() + " " + getLastSeen().toLocaleString();
	}

	// Sort in reverse order to get last seen on top
	public int compareTo(ServerInfo another) {
		return another.getLastSeen().compareTo(getLastSeen());
	}
	
}